package com.huangmb.anymark.app.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import com.huangmb.anymark.app.R;
import com.huangmb.anymark.app.activity.base.AppBaseActivity;
import com.huangmb.anymark.app.fragment.user.LoginFragment;

/**
 * @author hmb
 * @version 1.0
 * @since 2016/5/21 20:32
 */
public class LoginActivity extends AppBaseActivity{
    @Override
    protected void onInitView(Bundle savedInstanceState) {
        super.onInitView(savedInstanceState);
        setContentView(R.layout.activity_login);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
    }

    @Override
    protected void afterInitView(Bundle savedInstanceState) {
        super.afterInitView(savedInstanceState);
        getSupportFragmentManager().beginTransaction()
                .add(R.id.container,new LoginFragment())
                .commit();

    }

    @Override
    public void onBackPressed() {
        if (!hasLogin()){
            setResult(Activity.RESULT_CANCELED);
        }
        super.onBackPressed();
    }
}
